use crate::types::Route;
use yew_router::prelude::*;
use yew::prelude::*;

mod types;
mod routes;
mod components;
mod utils;

fn switch(route: Route) -> Html {
    match route {
        Route::Root => html! { <routes::root::Root /> },
        Route::NotFound => html! { <h1>{ "404" }</h1> },
    }
}

#[function_component(Main)]
fn app() -> Html {
    html! {
        <BrowserRouter>
            <Switch<Route> render={switch} /> // <- must be child of <BrowserRouter>
        </BrowserRouter>
    }
}

fn main() {
    wasm_logger::init(wasm_logger::Config::default());
    yew::Renderer::<Main>::new().render();
}
